package com.propertypoint.util;

import java.sql.*;


public class DBUtil {

	Connection con;

	// Database configuration
	public static String url = "";
	private static String dbdriver = "com.mysql.jdbc.Driver";
	public static String username = "";
	public static String password = "";
	
	private static DBUtil dbUtil;
	
	public static DBUtil getDBUtil() throws Exception {
		synchronized (DBUtil.class) {
			if (dbUtil == null) {
				dbUtil = new DBUtil();
			}
		}
		return dbUtil;
	}
	
	private DBUtil() throws Exception {
		
	}
    
	public Connection getConnection() throws Exception {
		try {

			Class.forName(dbdriver);
			return DriverManager.getConnection(url, username, password);

		} catch (Exception ex) {
			System.out.println("Exception in creating a database connection: "
					+ ex);
			throw new Exception("Couldn't open connection to database: "
					+ ex.getMessage());
		}

	}
     
}

